package com.hyt.it.ogt.controller.pj.teacherclient;

import cn.hutool.core.text.CharSequenceUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.common.apiInfor.DataType;
import com.hyt.exception.annotation.ThrowsAdvice;
import com.hyt.it.ogt.common.config.ApiVersionConstant;
import com.hyt.it.ogt.controller.base.BaseController;
import com.hyt.it.ogt.pj.common.Constants;
import com.hyt.it.ogt.pj.common.MarkException;
import com.hyt.it.ogt.pj.common.ResponseCode;
import com.hyt.it.ogt.pj.model.entity.ItemScore;
import com.hyt.it.ogt.pj.model.entity.Student;
import com.hyt.it.ogt.pj.model.vo.*;
import com.hyt.it.ogt.pj.service.*;
import com.hyt.loginfo.annotation.OgtPreAuthorize;
import com.hyt.loginfo.model.User;
import com.hyt.model.PageParam;
import com.hyt.swagger.ApiVersion;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * Description:
 *
 * @author yaojian
 * @version 1.0
 * @copyright Copyright (c) 海云天
 * @since 2022/2/28
 */
@Api(tags = "27.东方雨虹教师端评卷任务列表", value = "教师端评卷任务列表")
@ApiSort(value = 27)
@RestController
@RequestMapping("/teacher/project")
public class PjProjectController extends BaseController {

    private final Logger log = LoggerFactory.getLogger(PjProjectController.class);

    @Resource
    private IProjectService projectService;
    @Resource
    private ITaskService taskService;
    @Resource
    private IPaperItemService paperItemService;
    @Resource
    private IStudentService studentService;
    @Resource
    private IItemScoreService itemScoreService;


    @ApiOperationSort(value = 1)
    @ApiOperation(value = "27.1获取评卷列表", notes = "根据不同考试跳转现考现评和非现考现评")
    @RequestMapping("/getPage")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "projectName", value = "考试名称", dataType = DataType.STRING, required = false),
            @ApiImplicitParam(name = "mobileMark", value = "评卷端标志（0：移动端，1：pc端）", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "examState", value = "状态（未开始：0，进行中：1，已结束：2）", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "current", value = "当前页", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "size", value = "页大小", dataType = DataType.STRING, required = true),
    })
    @ApiResponses({
            @io.swagger.annotations.ApiResponse(code = 20000, message = "OK", response = ProjectVo.class),
    })
    @ApiVersion(group = {ApiVersionConstant.V2_3_11})
    @ThrowsAdvice(code = 500, print = "获取评卷列表异常")
    @OgtPreAuthorize(values = {"gl_pj_teacher"})
    public ApiResponse<IPage<ProjectVo>> getPage(PageParam<ProjectVo> pageParam, String projectName, String examState, String mobileMark) {
        String currUserId = getUserId();
        IPage<ProjectVo> projectVos = projectService.getPageProjectList(pageParam, currUserId, projectName, examState, mobileMark);
        return ApiResponse.<IPage<ProjectVo>>builder().code(ResponseCode.SUCCESS).data(projectVos).build();
    }

    @ApiOperationSort(value = 2)
    @ApiOperation(value = "27.2获取评卷任务信息数据(更新)", notes = "")
    @PostMapping("/getProjectInfo")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "projectId", value = "项目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "subjectId", value = "科目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "batchId", value = "批次id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "placeId", value = "考点id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "roomId", value = "考场id", dataType = DataType.STRING, required = true),
    })
    @ApiResponses({
            @io.swagger.annotations.ApiResponse(code = 20000, message = "OK", response = ProjectVo.class),
    })
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object getProjectInfo(String projectId, String subjectId, String batchId, String placeId, String roomId) {
        String currUserId = getUserId();
        try {
            ProjectVo projectVo = projectService.getProjectInfo(currUserId, projectId, subjectId, batchId, placeId, roomId);
            return ApiResponse.builder().code(ResponseCode.SUCCESS).data(projectVo).build();
        } catch (Exception e) {
            log.error("获取评卷任务信息数据:{}", e);
            return ApiResponse.builder().code(ResponseCode.ERROR).build();
        }

    }


    @ApiOperationSort(value = 3)
    @ApiOperation(value = "27.3获取评卷任务列表数据(更新)", notes = "")
    @PostMapping("/getStudentInfoPage")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "projectId", value = "项目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "subjectId", value = "科目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "batchId", value = "批次id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "placeId", value = "考点id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "roomId", value = "考场id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "name", value = "准考证号或姓名", dataType = DataType.STRING, required = false),
            @ApiImplicitParam(name = "examState", value = "评卷状态（未开始：0，进行中：1，已结束：2，全部：null）", dataType = DataType.STRING, required = false),
            @ApiImplicitParam(name = "absentState", value = "考生状态（（0：正常 1：缺席））", dataType = DataType.STRING, required = false),
            @ApiImplicitParam(name = "current", value = "当前页", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "size", value = "页大小", dataType = DataType.STRING, required = true),
    })
    @ApiResponses({
            @io.swagger.annotations.ApiResponse(code = 20000, message = "OK", response = TaskPageItemVo.class),
    })
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object getStudentInfoPage(PageParam<TaskPageItemVo> pageParam, String projectId, String subjectId, String batchId, String placeId, String roomId,
                                     String name, String examState, String absentState, String order, String sort) {
        String currUserId = getUserId();
        try {
            IPage<TaskPageItemVo> studentVoIPage = projectService.getStudentInfoPage(pageParam, currUserId, projectId, subjectId, batchId, placeId, roomId, name, examState, absentState, order, sort);
            return ApiResponse.builder().code(ResponseCode.SUCCESS).data(studentVoIPage).build();
        } catch (Exception e) {
            log.error("获取评卷任务列表数据:{}", e);
            return ApiResponse.builder().code(ResponseCode.ERROR).build();
        }
    }


    @ApiOperationSort(value = 4)
    @ApiOperation(value = "27.4评卷内容查看，评卷查看", notes = "‘当前评分’和‘总分’需要动态的在每个大题里面获取后计算出来")
    @PostMapping("/getStudentPaper")
    @ApiResponses({
            @io.swagger.annotations.ApiResponse(code = 20000, message = "OK", response = MarkDataVo.class),
    })
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object getStudentPaper(String pieceScoreId, String admissionNo, Integer mobileMark) {
        String userId = getUserId();
        try {
            MarkDataVo markDataVo = taskService.getStudentPaper(pieceScoreId, admissionNo, userId, null, mobileMark);
            return ApiResponse.builder().code(ResponseCode.SUCCESS).data(markDataVo).build();
        } catch (Exception e) {
            log.error("获取评卷任务列表数据", e);
            return ApiResponse.builder().code(ResponseCode.ERROR).build();
        }
    }

    @ApiOperationSort(value = 5)
    @ApiOperation(value = "27.5提交评卷内容", notes = Constants.SWAGGER_METHOD_NOTES)
    @PostMapping("/submitTask")
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object submitTask(@RequestBody MarkDataVo markDataVo) {
        User user = getCurrentUser();
        if (null == user || CharSequenceUtil.isEmpty(user.getId())) {
            return ApiResponse.builder().code(ResponseCode.ERROR).data("获取不到用户信息").build();
        }
        try {
            Integer code = taskService.submitTeacherTask(markDataVo, user.getId());
            return ApiResponse.builder().code(code).build();
        } catch (MarkException e) {
            log.error("submitTeacherTask error", e);
            return ApiResponse.builder().code(ResponseCode.ERROR).data(e.getMessage()).build();
        } catch (Exception e) {
            log.error("submitTeacherTask error", e);
            return ApiResponse.builder().code(ResponseCode.ERROR).data(e.getMessage()).build();
        }
    }

    @ApiOperationSort(value = 5)
    @ApiOperation(value = "27.5.2 保存评卷内容(新增)", notes = Constants.SWAGGER_METHOD_NOTES)
    @PostMapping("/saveTask")
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object saveTask(@RequestBody MarkDataVo markDataVo) {
        String userId = getUserId();
        try {
            Integer code = taskService.saveTask(markDataVo, userId);
            return ApiResponse.builder().code(code).build();
        } catch (MarkException e) {
            return ApiResponse.builder().code(ResponseCode.ERROR).data(e.getMessage()).build();
        } catch (Exception e) {
            return ApiResponse.builder().code(ResponseCode.ERROR).data(e.getMessage()).build();
        }
    }


    @ApiOperationSort(value = 6)
    @ApiOperation(value = "27.6获取下一份评卷(更新)", notes = Constants.SWAGGER_METHOD_NOTES)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "projectId", value = "项目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "subjectId", value = "科目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "batchId", value = "批次id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "placeId", value = "考点id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "roomId", value = "考场id", dataType = DataType.STRING, required = true),
    })
    @ApiResponses({
            @io.swagger.annotations.ApiResponse(code = 20000, message = "OK", response = MarkDataVo.class),
    })
    @PostMapping("/findTask")
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object findTask2(String projectId, String subjectId, String batchId, String placeId, String roomId) {
        String currUserId = getUserId();
        MarkDataVo markDataVo = taskService.findTeacherTask(currUserId, projectId, subjectId, batchId, placeId, roomId);
        if (markDataVo != null && StringUtils.isNotEmpty(markDataVo.getAdmissionNum())) {
            return ApiResponse.builder().code(ResponseCode.SUCCESS).data(markDataVo).build();
        } else {
            return ApiResponse.builder().code(ResponseCode.SUCCESS).data(null).build();
        }
    }


    @ApiOperationSort(value = 7)
    @ApiOperation(value = "27.7(添加字段)现考现评-主观题列表", notes = Constants.SWAGGER_METHOD_NOTES)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "projectId", value = "项目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "subjectId", value = "科目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "batchId", value = "批次id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "placeId", value = "考点名id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "roomId", value = "考场名Id", dataType = DataType.STRING, required = true),
    })
    @ApiResponses({
            @io.swagger.annotations.ApiResponse(code = 20000, message = "OK", response = PaperItemVo.class),
    })
    @PostMapping("/getPaperItemList")
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object getPaperItemList(String projectId, String subjectId, String batchId, String placeId, String roomId) {
        String currUserId = getUserId();
        try {
            MarkDataVo markDataVo = paperItemService.selectPaperItemVoList(projectId, subjectId, currUserId, batchId, placeId, roomId);
            return ApiResponse.builder().code(ResponseCode.SUCCESS).data(markDataVo).build();
        } catch (Exception e) {
            return ApiResponse.builder().code(ResponseCode.ERROR).data("获取数据失败").build();
        }
    }


    @ApiOperationSort(value = 8)
    @ApiOperation(value = "27.8现考现评-根据小题获取学生列表数据", notes = Constants.SWAGGER_METHOD_NOTES)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "projectId", value = "项目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "subjectId", value = "科目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "paperItem", value = "题目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "batchId", value = "批次id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "placeId", value = "考点名id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "roomId", value = "考场名Id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "name", value = "准考证或姓名", dataType = DataType.STRING, required = false),
            @ApiImplicitParam(name = "current", value = "当前页", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "size", value = "页大小", dataType = DataType.STRING, required = true)
    })
    @ApiResponses({
            @io.swagger.annotations.ApiResponse(code = 20000, message = "OK", response = StudentVo.class),
    })
    @PostMapping("/getStudentList")
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object getStudentList(PageParam<StudentVo> pageParam, String projectId, String subjectId, String paperItem, String placeId, String roomId, String batchId, String name) {
        String currUserId = getUserId();
        try {
            IPage<StudentVo> studentVoIPage = studentService.getStudentList(pageParam, projectId, subjectId, paperItem, placeId, roomId, batchId, name, currUserId);
            return ApiResponse.builder().code(ResponseCode.SUCCESS).data(studentVoIPage).build();
        } catch (Exception e) {
            return ApiResponse.builder().code(ResponseCode.ERROR).data("获取数据失败").build();
        }
    }


    @ApiOperationSort(value = 9)
    @ApiOperation(value = "27.9 现考现评-提交考生单个小答题评价（单个小题）", notes = Constants.SWAGGER_METHOD_NOTES)
    @PostMapping("/studentAnswerSingleEvaluate")
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object studentAnswerSingleEvaluate(ItemScoreSaveVo itemScoreSaveVo) {
        String currUserId = getUserId();
        itemScoreSaveVo.setUserId(currUserId);
        try {
            boolean flag = studentService.studentAnswerSingleEvaluate(itemScoreSaveVo, currUserId);
            return ApiResponse.builder().code(ResponseCode.SUCCESS).data(flag).build();
        } catch (Exception e) {
            log.error("studentAnswerSingleEvaluate error", e);
            return ApiResponse.builder().code(ResponseCode.ERROR).data("提交数据失败").build();
        }
    }


    @ApiOperationSort(value = 10)
    @ApiOperation(value = "27.10设置考试缺席", notes = Constants.SWAGGER_METHOD_NOTES)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "taskId", value = "任务id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "admissionNum", value = "准考证id", dataType = DataType.STRING, required = true),
    })
    @ApiResponses({
            @io.swagger.annotations.ApiResponse(code = 20000, message = "OK", response = Boolean.class),
    })
    @PostMapping("/setStudentAbsent")
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object setStudentAbsent(String taskId, String admissionNum) {
        String currUserId = getUserId();
        try {
            boolean flag = studentService.setStudentAbsent(taskId, admissionNum, currUserId);
            return ApiResponse.builder().code(ResponseCode.SUCCESS).data(flag).build();
        } catch (Exception e) {
            log.error("setStudentAbsent error", e);
            return ApiResponse.builder().code(ResponseCode.ERROR).data(e.getMessage()).build();
        }
    }


    @ApiOperationSort(value = 11)
    @ApiOperation(value = "27.11取消考生缺席", notes = Constants.SWAGGER_METHOD_NOTES)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "taskId", value = "任务id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "admissionNum", value = "准考证id", dataType = DataType.STRING, required = true),
    })
    @ApiResponses({
            @io.swagger.annotations.ApiResponse(code = 20000, message = "OK", response = Boolean.class),
    })
    @PostMapping("/setStudentNotAbsent")
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object setStudentNotAbsent(String taskId, String admissionNum) {
        String currUserId = getUserId();
        try {
            boolean flag = studentService.setStudentNotAbsent(taskId, admissionNum, currUserId);
            return ApiResponse.builder().code(ResponseCode.SUCCESS).data(flag).build();
        } catch (Exception e) {
            log.error("setStudentNotAbsent error", e);
            return ApiResponse.builder().code(ResponseCode.ERROR).data(e.getMessage()).build();
        }
    }

    @ApiOperationSort(value = 12)
    @ApiOperation(value = "27.12提交全部评卷", notes = Constants.SWAGGER_METHOD_NOTES)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "projectId", value = "项目id", dataType = DataType.STRING, paramType = "query", required = true),
            @ApiImplicitParam(name = "subjectId", value = "科目id", dataType = DataType.STRING, paramType = "query", required = true),
    })
    @ApiResponses({
            @io.swagger.annotations.ApiResponse(code = 20000, message = "OK", response = Boolean.class),
    })
    @PostMapping("/saveTaskByUser")
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object saveTaskByUser(String projectId, String subjectId, String batchId, String placeId, String roomId) {
        String currUserId = getUserId();
        try {
            boolean flag = taskService.saveTaskByUser(projectId, subjectId, currUserId, batchId, placeId, roomId);
            return ApiResponse.builder().code(ResponseCode.SUCCESS).data(flag).build();
        } catch (Exception e) {
            log.error("saveTaskByUser error", e);
            return ApiResponse.builder().code(ResponseCode.ERROR).data(e.getMessage()).build();
        }
    }


    @ApiOperationSort(value = 13)
    @ApiOperation(value = "27.13获取评卷的科目", notes = Constants.SWAGGER_METHOD_NOTES)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "projectId", value = "项目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "batchId", value = "批次id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "placeId", value = "考点id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "roomId", value = "考场id", dataType = DataType.STRING, required = true),
    })
    @ApiResponses({
            @io.swagger.annotations.ApiResponse(code = 20000, message = "OK", response = MarkSubjectVo.class),
    })
    @PostMapping("/getTaskSubject")
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object getTaskSubject(String projectId, String batchId, String placeId, String roomId) {
        String currUserId = getUserId();
        try {
            List<MarkSubjectVo> markSubjectVoList = taskService.getTaskSubject(currUserId, projectId, batchId, placeId, roomId);
            return ApiResponse.builder().code(ResponseCode.SUCCESS).data(markSubjectVoList).build();
        } catch (MarkException e) {
            return ApiResponse.builder().code(ResponseCode.ERROR).data(e.getMessage()).build();
        } catch (Exception e) {
            return ApiResponse.builder().code(ResponseCode.ERROR).data(e.getMessage()).build();
        }
    }

    @ApiOperationSort(value = 14)
    @ApiOperation(value = "27.14获取评卷的批次", notes = Constants.SWAGGER_METHOD_NOTES)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "projectId", value = "项目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "subjectId", value = "科目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "batchId", value = "批次id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "placeId", value = "考点id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "roomId", value = "考场id", dataType = DataType.STRING, required = true),
    })
    @ApiResponses({
            @io.swagger.annotations.ApiResponse(code = 20000, message = "OK", response = MarkBatchVo.class),
    })
    @PostMapping("/getTaskBatch")
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object getTaskBatch(String projectId, String subjectId, String batchId, String placeId, String roomId) {
        String currUserId = getUserId();
        try {
            List<MarkBatchVo> markBatchVoList = taskService.getTaskBatch(currUserId, projectId, subjectId, batchId, placeId, roomId);
            return ApiResponse.builder().code(ResponseCode.SUCCESS).data(markBatchVoList).build();
        } catch (MarkException e) {
            return ApiResponse.builder().code(ResponseCode.ERROR).data(e.getMessage()).build();
        } catch (Exception e) {
            return ApiResponse.builder().code(ResponseCode.ERROR).data(e.getMessage()).build();
        }
    }

    @ApiOperationSort(value = 15)
    @ApiOperation(value = "27.15获取评卷的状态", notes = Constants.SWAGGER_METHOD_NOTES)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "projectId", value = "项目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "subjectId", value = "科目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "batchId", value = "批次id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "placeId", value = "考点id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "roomId", value = "考场id", dataType = DataType.STRING, required = true),
    })
    @ApiResponses({
            @io.swagger.annotations.ApiResponse(code = 20000, message = "OK", response = MarkStatusVo.class),
    })
    @PostMapping("/getTaskStatus")
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object getTaskStatus(String projectId, String subjectId, String batchId, String placeId, String roomId) {
        String currUserId = getUserId();
        try {
            List<MarkStatusVo> markStatusVos = taskService.getTaskStatus(currUserId, projectId, subjectId, batchId, placeId, roomId);
            return ApiResponse.builder().code(ResponseCode.SUCCESS).data(markStatusVos).build();
        } catch (MarkException e) {
            return ApiResponse.builder().code(ResponseCode.ERROR).data(e.getMessage()).build();
        } catch (Exception e) {
            return ApiResponse.builder().code(ResponseCode.ERROR).data(e.getMessage()).build();
        }
    }

    @ApiOperationSort(value = 16)
    @ApiOperation(value = "27.16获取当前小题的信息", notes = "")
    @PostMapping("/getCurrPaperItemInfo")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "projectId", value = "项目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "subjectId", value = "科目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "itemId", value = "小题id", dataType = DataType.STRING, required = true),
    })
    @ApiResponses({
            @io.swagger.annotations.ApiResponse(code = 20000, message = "OK", response = PaperItemVo.class),
    })
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object getCurrPaperItemInfo(String projectId, String subjectId, String itemId) {
        String currUserId = getUserId();
        try {
            // 查询当前题目信息
            PaperItemVo itemVo = paperItemService.getCurrPaperItemInfo(currUserId, projectId, subjectId, itemId);
            return ApiResponse.builder().code(ResponseCode.SUCCESS).data(itemVo).build();
        } catch (Exception e) {
            log.error("获取评卷任务列表数据:" + e.getMessage());
            return ApiResponse.builder().code(ResponseCode.ERROR).build();
        }
    }


    @ApiOperationSort(value = 18)
    @ApiOperation(value = "27.18获取考生信息数据", notes = "")
    @PostMapping("/getStudentInfo")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "projectId", value = "项目id", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "admissionNo", value = "考生准考证号", dataType = DataType.STRING, required = true),
            @ApiImplicitParam(name = "itemId", value = "小题id", dataType = DataType.STRING, required = true),

    })
    @ApiResponses({
            @io.swagger.annotations.ApiResponse(code = 20000, message = "OK", response = Student.class),
    })
    @ApiVersion(group = ApiVersionConstant.V2_3_11)
    public Object getStudentInfo(String projectId, String admissionNo, String itemId) {
        try {
            String currUserId = getUserId();
            QueryWrapper<Student> select = new QueryWrapper<>();
            select.lambda().eq(Student::getProjectId, projectId).eq(Student::getAdmissionNum, admissionNo);
            Student student = studentService.getOne(select);
            StudentVo studentVo = new StudentVo();
            if (null != student) {
                BeanUtils.copyProperties(student, studentVo);
            }
            QueryWrapper<ItemScore> itemScoreQueryWrapper = new QueryWrapper<>();
            itemScoreQueryWrapper.lambda().eq(ItemScore::getItemId, itemId).eq(ItemScore::getEncodeId, admissionNo)
                    .eq(ItemScore::getUserId, currUserId);
            ItemScore itemScore = itemScoreService.getOne(itemScoreQueryWrapper);
            studentVo.setItemScore(null == itemScore ? BigDecimal.ZERO : itemScore.getScore());
            studentVo.setRemark(null == itemScore ? "" : itemScore.getRemark());
            return ApiResponse.builder().code(ResponseCode.SUCCESS).data(studentVo).build();
        } catch (Exception e) {
            log.error("获取评卷任务列表数据:" + e.getMessage());
            return ApiResponse.builder().code(ResponseCode.ERROR).build();
        }
    }

}
